package com.txy.domain.strategy.service.rule.chain.impl;

import com.txy.domain.strategy.model.vo.RuleLogicCheckTypeVO;
import com.txy.domain.strategy.service.armory.IStrategyDispatch;
import com.txy.domain.strategy.service.rule.chain.AbstractLogicChain;
import com.txy.domain.strategy.service.rule.chain.factory.LogicChainFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component("default")
public class DefaultLogicChain extends AbstractLogicChain {
    @Resource
    private IStrategyDispatch dispatch;

    @Override
    public LogicChainFactory.LogicChainRes logic(Long strategyId, String userId) {
        log.info("规则过滤-责任链-DEFAULT默认规则: strategyId={}, userId={}", strategyId, userId);
        Integer awardId = dispatch.getRandomAwardId(strategyId);
        log.info("规则过滤-责任链-DEFAULT默认规则接管, awardId={}", awardId);
        return LogicChainFactory.LogicChainRes.builder()
                .ruleLogicCheckTypeVO(RuleLogicCheckTypeVO.TAKE_OVER)
                .logicModel(LogicChainFactory.LogicModel.DEFAULT)
                .logicChainAward(LogicChainFactory.LogicChainAward
                        .builder().awardId(awardId)
                        .build())
                .build();
    }

}
